package com.atguigu.lease.web.app.service.impl;


import com.atguigu.lease.web.app.service.LoginService;
import com.atguigu.lease.web.app.utils.SMSUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public void sendMsg(String phone) {
        //1生成六位的随机数字作为验证码
        String code = RandomStringUtils.randomNumeric(6);
        //2调用发送短信到工具类,发送短信
        SMSUtils.send(code,phone);
        //3将生成的验证码保存在redis中,用统一前缀+手机号,作为唯一的key
//        stringRedisTemplate.opsForValue().set(RedisConstant.APP_LOGIN_PREFIX+phone,code,5, TimeUnit.MINUTES);


    }
}
